﻿#include "ZigZagConvert.h"

#ifdef DEV_TEST
#include <gtest/gtest.h>

struct ZigZagConvertTestCase
{
	std::string inputString;
	int inputNumRows;
	std::string expectResult;

	friend std::ostream& operator<<(std::ostream& os, const ZigZagConvertTestCase& obj)
	{
		return os
			<< "inputString: " << obj.inputString
			<< " inputNumRows: " << obj.inputNumRows
			<< " expectResult: " << obj.expectResult;
	}
};

class ZigZagConvertTest :public SolutionTestor<IZigZagConvert, testing::TestWithParam<ZigZagConvertTestCase>>
{
protected:
	void LoadSolutions(std::vector<IZigZagConvert*>& solutions) override
	{
		solutions = {
			new ZigZagConvert::Monitor,
			new ZigZagConvert::DirectTransfer,
		};
	}
};

TEST_P(ZigZagConvertTest, convert)
{
	TestForSolutions([](IZigZagConvert* solution)
		{
			const auto testCase = GetParam();
			auto result = solution->convert(testCase.inputString, testCase.inputNumRows);
			EXPECT_EQ(result, testCase.expectResult);
		});
}

INSTANTIATE_TEST_SUITE_P(ValidityTestCases, ZigZagConvertTest, testing::Values(
	ZigZagConvertTestCase{ "PAYPALISHIRING",3,"PAHNAPLSIIGYIR" },
	ZigZagConvertTestCase{ "PAYPALISHIRING",4,"PINALSIGYAHRPI" },
	ZigZagConvertTestCase{ "A",1,"A" }
));

#endif
